<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.wanmait.hotelManage.vo.RoomTypeComment"%>
<%@page import="com.wanmait.hotelManage.vo.RoomTypeCommentReport"%>
<%@page import="java.util.List"%>
<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%
    String path=request.getContextPath();
    List<RoomTypeCommentReport>RoomTypeCommentReports=(List<RoomTypeCommentReport>)request.getAttribute("roomTypeCommentReports");
    List<RoomTypeComment>RoomTypeComments=(List<RoomTypeComment>)request.getAttribute("roomTypeComments");
    String text=(String)request.getAttribute("text");
    %>
<table class="result-tab" width="100%">
                       <tr>
                            <th class="tc" width="5%"><input class="allChoose" name="" type="checkbox"></th>
                            <th>序号</th>
                            <th>ID</th>
                            <th>举报人</th>
                            <th>举报内容</th>
                            <th>举报原因</th>
                            <th>被举报人</th>
                            <th>举报时间</th>
                            <th>审核</th>
                        </tr>
                        <%
                        if(RoomTypeCommentReports!=null&&RoomTypeComments!=null){
                        	DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        	for(int i=0;i<RoomTypeCommentReports.size();i++){
                        		RoomTypeCommentReport roomTypeCommentReport=RoomTypeCommentReports.get(i);
                        		RoomTypeComment roomTypeComment=RoomTypeComments.get(i);
                        		String inputTime=df.format(roomTypeCommentReport.getInputTime());
                        		String rtcinputTime=df.format(roomTypeComment.getInputTime());
                        		%>
                        		<tr id="tr<%=roomTypeCommentReport.getId()%>">
                            <td class="tc"><input data-id="<%=roomTypeCommentReport.getId()%>" class="choose" name="id[]" value="59" type="checkbox"></td>
                            <td><%=i+1 %></td>
                            <td><%=roomTypeCommentReport.getId() %></td>
                             <td><%=roomTypeCommentReport.getUserinfo().getUsername() %></td>
                            <td style="width:500px;height:100px"><%=roomTypeComment.getContent() %></td>
                            <td><%=roomTypeCommentReport.getReason() %></td>
                            <td><%=roomTypeComment.getUserinfo().getUsername() %></td>
                             <td><%=inputTime %></td>
                            <td>
                                <a class="link-update" href="<%=path%>/manage/RoomTypeCommentReportServlet?action=updateby&id=<%=roomTypeCommentReport.getId()%>&id1=<%=roomTypeComment.getId() %>">通过</a>
                                <a class="link-del" id="de<%=roomTypeCommentReport.getId()%>" href="javaScript:void(0)">打回</a>
                            </td>
                        </tr>
                        		<%
                        	}
                        }
                        %>
                    </table>
                  <div class="qwe">
                    <%
                    Pager pager=(Pager)request.getAttribute("pager");
                    if(pager!=null){
                    	 int start= 1;
                         int end =pager.getPageCount();
                         if(pager.getPageCount()>5){
                        	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                        	 end=start+4;
                        	 if(end>pager.getPageCount()){
                        		 end=pager.getPageCount();
                        		 start=end-4;
                        	 }
                         }
                         %>
                         [<a class="ok" href="javascript:void(0)">上一页</a>]
                         <%
                    	for(int i=start;i<=end;i++){
                    		if(pager.getPageNo()!=i){
                    		%>
                    		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}else{
                    		%>
                    		[<a class="aaa" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}
                    }
                         %>
                         [<a class="no" href="javascript:void(0)">下一页</a>]
                         <%
                    }
                    %>
                    </div>
                    <script>
                    $(function(){
                    	$("#batchUp").click(function(){
                    		var arr=[];
                    		$(".choose:checked").each(function(){
                    			var id=$(this).data("id");
                    			arr.push(id);
                    		})
                    		if(arr.length>0){
                    			$.ajax({
                    				url:"<%=path%>/manage/RoomTypeCommentReportServlet?action=updaeups",
                    				data:{ids:arr.toString()},
                    				success:function(){
                    					for(var i=0;i<arr.length;i++){
                    						$("#tr"+arr[i]).remove();
                    					}
                    				}
                    			})
                    		}
                    	})
                    	$("#batchDel").click(function(){
                    		var arr=[];
                    		$(".choose:checked").each(function(){
                    			var id=$(this).data("id");
                    			arr.push(id);
                    		})
                    		if(arr.length>0){
                    			$.ajax({
                    				url:"<%=path%>/manage/RoomTypeCommentReportServlet?action=updaeNoups",
                    				data:{ids:arr.toString()},
                    				success:function(){
                    					for(var i=0;i<arr.length;i++){
                    						$("#tr"+arr[i]).remove();
                    					}
                    				}
                    			})
                    		}
                    	})
                    	$(".no").click(function(){
							/* $(".number").css("color","black");
							$(this).css("color","red"); */
							var cont=<%=pager.getPageNo()%>;
							if(cont<<%=pager.getPageCount()%>){
							cont++;
							}
							$.ajax({
                    			url:"<%=path%>/manage/RoomTypeCommentReportServlet?action=searchTwo&text=<%=text%>",
                    				data:{id:cont},
                    					success:function(msg){
                    						$("#pagerdiv").html(msg);
                    					}
                    		})
						})
	$(".ok").click(function(){
		/* $(".number").css("color","black");
		$(this).css("color","red"); */
		var cont=<%=pager.getPageNo()%>;
		if(cont>1){
		cont--;
		}
		$.ajax({
			url:"<%=path%>/manage/RoomTypeCommentReportServlet?action=searchTwo&text=<%=text%>",
				data:{id:cont},
					success:function(msg){
						$("#pagerdiv").html(msg);
					}
		})
	})
        $(".number").click(function(){
		var cont=$(this).html();
		$.ajax({
			url:"<%=path%>/manage/RoomTypeCommentReportServlet?action=searchTwo&text=<%=text%>",
				data:{id:cont},
					success:function(msg){
						$("#pagerdiv").html(msg);
					}
		})
	})
	$(".aaa").click(function(){
		var cont=$(this).html();
		$.ajax({
			url:"<%=path%>/manage/RoomTypeCommentReportServlet?action=searchTwo&text=<%=text%>",
				data:{id:cont},
					success:function(msg){
						$("#pagerdiv").html(msg);
					}
		})
	})
	
                    })
                    </script>
					<style>
					.qwe{
						text-align:center;
						}
					</style>
					<script>
					$(".aaa").css("color","red");
					</script>
					<style>
					.qwe{
						text-align:center;
						}
						.aaa{
						text-align:center;
						}
					</style>